package com.explorati.design_pattern.hybrid.specification;

import java.util.ArrayList;

//用户操作类
public class UserProvider implements IUserProvider {

	private ArrayList<User> userList;

	public UserProvider(ArrayList<User> userList) {
		this.userList = userList;
	}

	@Override
	public ArrayList<User> findUser(IUserSpecification userSpec) {
		ArrayList<User> result = new ArrayList<>();
		for (User user : userList) {
			// 符合指定规格的用户
			if (userSpec.isSatisfiedBy(user)) {
				result.add(user);
			}
		}
		return result;
	}

}
